Categorygithub.com/abakum/term
modulepackage
0.0.1
Repository: https://github.com/abakum/term.git
Documentation: pkg.go.dev

# README

term - utilities for dealing with terminals

Test GoDoc Go Report Card

term provides structures and helper functions to work with terminal (state, sizes).

Using term

package main

import (
	"log"
	"os"

	"github.com/abakum/term"
)

func main() {
	fd := os.Stdin.Fd()
	if term.IsTerminal(fd) {
		ws, err := term.GetWinsize(fd)
		if err != nil {
			log.Fatalf("term.GetWinsize: %s", err)
		}
		log.Printf("%d:%d\n", ws.Height, ws.Width)
	}
}

Contributing

Want to hack on term? Docker's contributions guidelines apply.

Copyright and license

Code and documentation copyright 2015 Docker, inc. Code released under the Apache 2.0 license. Docs released under Creative commons.

# Packages

No description provided by the author

# Functions

DisableEcho applies the specified state to the terminal connected to the file descriptor, with echo disabled.
GetFdInfo returns the file descriptor for an os.File and indicates whether the file represents a terminal.
GetWinsize returns the window size based on the specified file descriptor.
IsTerminal returns true if the given file descriptor is a terminal.
MakeRaw puts the terminal (Windows Console) connected to the given file descriptor into raw mode and returns the previous state of the terminal so that it can be restored.
NewEscapeProxy returns a new TTY proxy reader which wraps the given reader and detects when the specified escape keys are read, in which case the Read method will return an error of type EscapeError.
No description provided by the author
RestoreTerminal restores the terminal connected to the given file descriptor to a previous state.
SaveState saves the state of the terminal connected to the given file descriptor.
SetRawTerminal puts the terminal connected to the given file descriptor into raw mode and returns the previous state.
SetRawTerminalOutput puts the output of terminal connected to the given file descriptor into raw mode.
SetWinsize tries to set the specified window size for the specified file descriptor.
StdStreams returns the standard streams (stdin, stdout, stderr).
ToBytes converts a string representing a suite of key-sequence to the corresponding ASCII code.

# Variables

ASCII list the possible supported ASCII key sequence.
ErrInvalidState is returned if the state of the terminal is invalid.

# Structs

EscapeError is special error which returned by a TTY proxy reader's Read() method in case its detach escape sequence is read.
No description provided by the author
Winsize represents the size of the terminal window.

# Type aliases

State holds the platform-specific state / console mode for the terminal.
Termios is the Unix API for terminal I/O.